//注销功能
function logout() {
    if (confirm("确认退出登录")) {
        jQuery.ajax({
            url: '/user/logout',
            type: 'post',
            data: {},
            success: function (result) {
                if (result != null && result.code == 200) {
                    alert("退出成功");
                    location.href = "/index.html";
                } else {
                    alert("抱歉:登录后再试!");
                    location.href = '/index.html';
                }
            }
        })
    }
}


// 获取当前url参数的公共方法
function getUrlValue(key) {
    //ex: ?id=1&v=2   location.search获取query string
    var params = location.search;
    //如果有query string,则去找id对应的value
    if (params.length > 1) {
        params = location.search.substring(1); //去掉?字符
        //ex: id=1&v=2
        var paramArr = params.split("&");
        for (var i = 0; i < paramArr.length; i++) {
            var kv = paramArr[i].split("=");
            //在url中找到id这个key值
            if (kv[0] == key) {
                //返回key对应的value
                return kv[1];
            }
        }
    }
    //没有query string 返回空
    return "";
}